[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 class                   Class Definition Type

  class classname [:baselist] {
     [member list] }

            Classes are the fundamental basis of C++ -- you declare
    objects with the class keyword. Objects are much like structs in C,
    except that they can also contain functions and have other
    attributes. Classes are specific to C++.
            In the definition above, classname is the name of the class
    you are creating. The option identifier baselist specifies the base
    class from which objects of type classname will inherit objects and
    methods. The list memberlist defines the classes members -- both data
    and member functions.
            By default, all members of a class are private, which means
    that they are accessible only by member functions. However, you can
    list member variables and member functions as public, like this:

            class fish {
                int num_fish;
            public:
                void increment_num_fish(void);
                void decrement_num_fish(void);
            };

            void fish::increment_num_fish(void);
            {
                num_fish++;
            }

            void fish::decrement_num_fish(void);
            {
                num_fish--;
            }

   -------------------------------- Examples --------------------------------
    This example creates a class called birdwatch.

              class birdwatch {
                 int num_finches;
                 int num_seagulls;
              public:
                 int finch_spotted(void);
                 int seagull_spotted(void);
              };

See Also: public private protected friend
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson